const app = getApp()

Page({
  data: {
    showAnswer: false,
    answer:"",
    // 答题类型
    // 0 看广告查看答案
    // 1 继续答题
    // 2 今日答题份额已用完
    type: 0,
  },
  
  onLoad() {
    tt.createLiveCard({
      url: '/live-card/game',
      width: 130,
      height: 160,
      success: () => {
        console.info('Live card created!');
      },
      fail: (errMsg) => {
        console.error('Live card create failed:!', errMsg);
      },
    });
  },
  onHide: function () {
    this.initPage()
  },
  onUnload: function () {
    this.initPage()
  },
  onShow: function () {
    this.initPage()
  },
  onItemClick() {
    // tt.navigateTo({
    //   url: `pg_life-cycle-page?params=navigateTo`, //demo示例，一般路径形式：/pages/detail/detail?key=${value}
    //   success(res) {
    //     console.log(res);
    //   },
    //   fail(res) {
    //     console.log("navigateTo调用失败", res);
    //   },
    // });
    
    this.setData({
      showAnswer: true,
      answer: "这是正确答案",
      type: 1
    })

  },

  initPage(){
    this.setData({
      showAnswer: false,
      answer: "",
      type: 0
    })
  }

})
